
from car import Car
from skmath import myrand

cars = []

# create ten cars
for i in range(20):
    c = Car(i)
    c.startTime = myrand.randStartTime()
    c.speed = myrand.randSpeed()

    cars.append( c )

for c in cars:
    print("car: ", c.id, "clolor: ", c.color, "start time:", c.startTime, "pos: ", c.pos )
    
## 开始仿真
T = 0  # current time
t_step = 1
max_t = 1000
while True:
    for c in cars:
        if T>= c.startTime:
            c.run()

    T += t_step
    print("current time: ", T)
    if T >= 1000:
        break

print("Finished creating cars")


